import Vue from 'vue'
import App from './App'
import store from './store'
import mixin from './mixin/index.js'
import tabbar from 'components/tabbar/tabbar.vue'
import mContainer from 'components/mContainer/mContainer.vue'

Vue.mixin(mixin)
Vue.component('tabbar',tabbar)
Vue.component('m-container',mContainer)

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
    ...App,
	store
})
app.$mount()

//#ifdef mp-weixin
uni.getNetworkType({
    success: function (res) {
        console.log(res.networkType);
		// alert(res.networkType)
		    store.dispatch('updateNetwork', {
		        onLine: res.networkType == "none" ? false :true
		    })
    }
});

uni.onNetworkStatusChange(function (res) {
    console.log(res.isConnected);
    console.log(res.networkType);
	// alert(res.networkType)
	store.dispatch('updateNetwork', {
	    onLine: res.networkType == "none" ? false :true
	})
})
//#endif


//#ifdef H5  || APP-PLUS  || MP-ALIPAY
window.addEventListener('online', function() {
    store.dispatch('updateNetwork', {
        onLine: true
    })
});

window.addEventListener('offline', function() {
    store.dispatch('updateNetwork', {
        onLine: false
    })
});
//#endif